import { h, render, defineComponent } from "vue";
import ShowInfo from "./index.vue";

/**
 * @param {*} title 标题
 * @param {*} content 内容
 * @param {*} cancelText 取消文本
 * @param {*} confirmText 确认文本
 */
export const showInfoBox = ({el, positionLeft, positionTop, slot }) => {
  return new Promise((resolve, reject) => {
    if (!positionLeft) positionLeft = "0px";
    if (!positionTop) positionTop = "0px";
    // 关闭弹层事件
    const close = () => {
      render(null, document.body);
    };
    const show = () => {
      console.log("slot", slot);
      // 1. 生成 vnode
      const vnode = h(
        ShowInfo,
        {
          left: positionLeft,
          top: positionTop,
        },
        {
          default:()=> h(slot)
        }
      );

      const dom = document.getElementById(el) || document.body
      dom.style.position = 'relative'
      // 2. render 渲染
      render(vnode,dom);
  
    };

    show();
  });
};
